import { consola } from 'consola';
import { default as colors } from 'chalk';
import { cac } from 'cac';

import { defineRunCommand } from './commands/run';
import { defineLintCommand } from './commands/lint';
import { defineDtsCommand } from './commands/dts';

try {
    const great = cac('great');

    defineRunCommand(great);
    defineLintCommand(great);
    defineDtsCommand(great);

    great.on('command:*', () => {
        consola.error(colors.red('Invalid command!'));
        process.exit(1);
    });

    great.usage('great');
    great.help();
    great.parse();
} catch (error) {
    consola.error(error);
    process.exit(1);
}
